<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
</head>

<body>
    <form>
        <p>
            邮箱：<input type="text" id="email" />
        </p>
        <p>
            密码：<input type="password" id="password" />
        </p>
        <input type="button" onclick="login()" value="登录" />
    </form>
    <script src="https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script>
        function login() {
            $.ajax({
                url: "/api/user/login/" + $("#email").val() + "/" + $("#password").val(),
                type: 'get',
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("请正确输入账号密码");
                },
                xhrFields: { withCredentials: true },
                success: function (data, status, xhr) {
                    if (data != "" || data != null) {
                        $.cookie('token', data, { expires: 1 });
                        window.location.href = "welcome.html";
                    }
                }
            });
        }
    </script>
</body>

</html>